package com.bigevent.controller;


import com.bigevent.pojo.Article;
import com.bigevent.pojo.PageBean;
import com.bigevent.pojo.Result;
import com.bigevent.pojo.User;
import com.bigevent.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/manager")
public class ManagerController {

    @Autowired
    private ManagerService managerService;
    /*
    * 查看所有作者
    * */
    @GetMapping("/author/list")
    public Result<PageBean<User>> list(
            Integer pageNum,
            Integer pageSize
    ){
        PageBean<User> list = managerService.listAuthor(pageNum,pageSize);
        return Result.success(list);
    }

    /*
    * 设为管理
    * */
    @PutMapping("/author/{userId}")
    public Result updateStatus(@PathVariable Integer userId){
        managerService.updateStatus(userId);
        return Result.success();
    }

    /*
    * 降为用户
    * */
    @PutMapping("/author/cancel/{userId}")
    public Result cancelUpdateStatus(@PathVariable Integer userId){
        managerService.cancelStatus(userId);
        return Result.success();
    }

    /*
    * 删除用户
    * */
    @DeleteMapping("/author/{userId}")
    public Result delete(@PathVariable Integer userId){
        managerService.delete(userId);
        return Result.success();
    }
}